package cn.cloud.butler.scheduled.service;

import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashSet;

@Service
public class MacAlarmService {

    public Integer AdjustAlarmType(String alarmIdStr) {
        StringBuilder a= new StringBuilder(alarmIdStr);
        if(a.length()==9){
            a.replace(4,5,"0");
        }
        alarmIdStr =a.toString();
        HashSet<String> alarmLevel1 = new HashSet<>();
        HashSet<String> alarmLevel2 = new HashSet<>();
        HashSet<String> alarmLevel3 = new HashSet<>();

        Collections.addAll(alarmLevel1, "500000016", "800000004", "300000003", "300000004", "300000007", "300000012", "300000016", "300000103", "300000104", "300000116");

        Collections.addAll(alarmLevel2, "500000000", "500000008","500000014", "300000002", "300000006", "300000009", "300000010", "300000011", "300000013",
                "300000025", "300000026", "300000035", "300000102", "300000106", "300000131", "300000132", "300000133", "100000013", "100000015", "200000004", "200000006", "200000021");

        Collections.addAll(alarmLevel3, "500000001", "500000002", "500000003", "500000004", "500000005", "500000006", "500000009", "500000010",
                "500000011", "500000012", "500000013", "500000021", "500000022", "500000023", "500000024", "500000025",
                "500000026", "500000027","500000028", "500000029","500000030", "500000031","500000032",
                "300000017", "300000019", "300000001", "300000008", "300000014", "300000015", "300000020", "300000021", "300000022", "300000023",
                "300000024", "300000027", "300000028", "300000029", "300000031", "300000033", "300000034", "300000036", "300000037",
                "300000038", "300000039", "300000040", "300000041", "300000042", "300000101", "300000107", "300000108", "300000109", "300000110", "300000111", "300000112",
                "300000113", "300000114", "300000117", "300000119", "300000123", "300000124", "300000125", "300000126", "300000129", "300000130", "800000014",
                "100000011", "100000016");

        if(alarmLevel1.contains(alarmIdStr)){
            return 1;
        }else if (alarmLevel2.contains(alarmIdStr)){
            return 2;
        }else if (alarmLevel3.contains(alarmIdStr)){
            return 3;
        }else {
            return 4;
        }
    }

}
